//
//  ViewController.swift
//  KeyboardDemo
//
//  Created by Lucky on 16/5/13.
//  Copyright © 2016年 Lucky. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var textView: UITextView!
    
    @IBOutlet weak var showLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.lightGrayColor()
        
        addChildViewController(emoticonVC)
        
        textView.inputView = emoticonVC.view
     
        textView.font = UIFont.systemFontOfSize(20)
    
    }
    
    @IBAction func showBtnClick(sender: AnyObject) {
        
        self.showLabel.text = self.textView.emoticonAttributedText()
        
        print(self.textView.emoticonAttributedText())
        
    }
    

    private lazy var emoticonVC: EmoticonViewController = EmoticonViewController { [unowned self] (emoticon) in
        
        self.textView.insertEmoticon(emoticon)
        
    }

    
}

